﻿namespace FlexField.Metadata
{
    /// <summary>
    /// Provides an abstraction for a validating a field.
    /// </summary>
    /// <typeparam name="TKey">The type used for the primary key for the field.</typeparam>
    public interface IFieldValidator<TKey> where TKey : IEquatable<TKey>
    {
        /// <summary>
        /// Validates a field as an asynchronous operation.
        /// </summary>
        /// <param name="manager">The <see cref="MetadataManager{TKey}"/> managing the metadata schema.</param>
        /// <param name="entityId">The primary key of the entity that the field belongs to.</param>
        /// <param name="field">The field to validate.</param>
        /// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="MetadataResult"/> of the asynchronous validation.</returns>
        Task<MetadataResult> ValidateAsync(MetadataManager<TKey> manager, TKey entityId, MetadataField<TKey> field);
    }
}
